import { createApp } from "vue";
import "./style.css";
import App from "./App.vue";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import router from "./router";

const app = createApp(App);

console.log(import.meta.env.VITE_BASE_URL);

app.use(ElementPlus);

import components from "./components/index";
app.use(components);

app.directive("focus", {
    beforeMount(el: HTMLElement) {
        console.log("beforeMount", el);
    },
    mounted(el: HTMLElement) {
        console.log("mounted", el);
        el.focus(); // 挂载完成后自动获取焦点
    },
    beforeUpdate(el: HTMLElement) {
        console.log("beforeUpdate", el);
    },
    updated(el: HTMLElement) {
        console.log("updated", el);
    },
    beforeUnmount(el: HTMLElement) {
        console.log("beforeUnmount", el);
    },
    unmounted(el: HTMLElement) {
        console.log("unmounted", el);
    },
});

app.config.globalProperties.getTime = () => {
    return new Date().toLocaleString();
};

import { resetRouter } from "./router/index";
resetRouter();
app.use(router);

import { createPinia } from "pinia";
const pinia = createPinia();
app.use(pinia);

app.mount("#app");
